package com.kehongborui.fliggy.mapper;

import com.kehongborui.fliggy.entity.PassStation;
import com.kehongborui.fliggy.model.PassStationModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PassStationMapper {

    /**
     * 批量插入经停站数据
     * @param passStationList
     * @return
     */
    int insertBatch(List<PassStation> passStationList);

    /**
     * 通过乘客定单上的起始站与终点站查找，该乘客所需要经过的所有车站
     * @param ids 起始id与终点id
     * @return
     */
    List<Integer> findPassStationById(List<Long> ids);

    /**
     * 根据列车的编号查询对应列车的经停站,用于列车查询结果的经停信息显示
     * @param vehicleNo
     * @return
     */
    List<PassStation> findPassStationByVehicleNo(String vehicleNo);

    /**
     * 根据索要经过的车站统计总价格
     * @param depSeq
     * @param arrSeq
     * @return
     */
    Long totalPrice(@Param("depSeq") Integer depSeq, @Param("arrSeq") Integer arrSeq, @Param("vehicleId") Long vehicleId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    @Delete({
        "delete from khbr_pass_station",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    @Insert({
        "insert into khbr_pass_station (id, vehicle_id, ",
        "seq, station_id, arr_time, ",
        "dep_time, stop_time, ",
        "create_time, update_time, ",
        "unit_price)",
        "values (#{id,jdbcType=BIGINT}, #{vehicleId,jdbcType=BIGINT}, ",
        "#{seq,jdbcType=TINYINT}, #{stationId,jdbcType=BIGINT}, #{arrTime,jdbcType=VARCHAR}, ",
        "#{depTime,jdbcType=VARCHAR}, #{stopTime,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{unitPrice,jdbcType=INTEGER})"
    })
    int insert(PassStation record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    int insertSelective(PassStation record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "id, vehicle_id, seq, station_id, arr_time, dep_time, stop_time, create_time, ",
        "update_time, unit_price",
        "from khbr_pass_station",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    PassStation selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(PassStation record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table khbr_pass_station
     *
     * @mbggenerated
     */
    int updateByPrimaryKey(PassStation record);
}